﻿@using System.Web.Optimization
@model dynamic
@{
    Layout = null;
}


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>雪绒花_订单管理_全部订单管理</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    @Styles.Render("~/Themes/default/css/cp.globle.min6.css")
    @Scripts.Render("~/Themes/default/js/cp.globle.min6.js")
        <!--去除顶层加载中 14-10-17 By 唐有炜-->
        <script type="text/javascript">
            //=============================================================
            //去除顶层加载中
            $(document).ready(function () {
                //去除加载中
                if (undefined != top.dialog.list["show_loading"]) {
                    top.dialog.list["show_loading"].close().remove();
                    //showTopMsg("页面加载成功！", "温馨提示", "Success");
                }
            });
            //=====================================================================
        </script>


        <script type="text/javascript">
    //全局变量
    var order_grid;

    $(function () {

        //初始化表格
        InitOrderGrid();
    });
    function InitOrderGrid() {
        order_grid = $("#order_grid_data").bootgrid({
            ajax: true,
            url: "/api/OrderApi/GetBootGridOrders",
            selection: true,
            multiSelect: true,
            rowSelect: false,
            keepSelection: true,
            rowCount: [10, 30, 50],
            templates: {
                header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\"><div class=\"col-sm-12 actionBar\"><div class=\"btn-group\" style=\"float:left;\"><button class=\"btn btn-default tip\" title=\"\" onclick=\"return order_trash(); \"><span class=\"glyphicon glyphicon glyphicon glyphicon-remove\"></span>作废该订单</button><button class=\"btn btn-default tip\" title=\"\" onclick=\"return order_update(); \"><span class=\"glyphicon glyphicon glyphicon glyphicon-minus\"></span>更改为执行中</button><button class=\"btn btn-default tip\" title=\"\" onclick=\"return order_wan(); \"><span class=\"glyphicon glyphicon glyphicon glyphicon-ok\"></span>更改为订单完成</button><button class=\"btn btn-default tip\" title=\"订单转移\" onclick=\"return  order_transfer(); \"><span class=\"glyphicon glyphicon glyphicon glyphicon-share-alt\"></span>订单转移</button></div>" +
                    "<div class=\"search form-group\"><div class=\"input-group\"><span class=\"icon glyphicon input-group-addon glyphicon-search\"></span> <input type=\"text\" class=\"search-field form-control\" placeholder=\"输入关键字\"></div></div>" +
                    "<p class=\"{{css.actions}}\"></p></div></div></div>"
            },
            labels: {
                all: "all", //checkbox全选的值
                search: "请输入名称",
                loading: "加载中...",
                noResults: "对不起，暂无符合条件的记录！",
                refresh: "刷新",
                infos: "从{{ctx.start}} 到 {{ctx.end}}，共{{ctx.total}} 条记录"
            },
            formatters: {
                OrderStatus: function (colum, row) {
                    switch (row.OrderStatus) {
                        case 0:
                            return "<span style=\"color:orange\">已作废</span>";
                        case 1:
                            return "<span style=\"color:red\">待处理</span>";
                        case 2:
                            return "<span style=\"color:#b806a9\">待执行</span>";
                        case 3:
                            return "<span style=\"color:#2701e9\">执行中</span>";
                        case 4:
                            return "<span style=\"color:#e90122\">订单完成</span>";
                        default:
                            return "";
                            break;
                    }
                },
                OrderEnd: function (column, row) {
                    switch (row.OrderStatus) {
                        case 1:
                            return "<span style=\"color:red\">(预定) </span>" + row.OrderBegin + "至" + row.OrderEnd;
                        case 2:
                            return "<span style=\"color:red\">(预定) </span>" + row.OrderBegin + "至" + row.OrderEnd;

                        case 3:
                            return "<span style=\"color:green\">(服务) </span>" + row.OrderBegin + "至" + row.OrderEnd;
                        case 4:
                            return "<span style=\"color:red\">(服务) </span>" + row.OrderBegin + "至" + row.OrderEnd;
                        default:
                            return "";
                            break;
                    }
                },
                "OrderCreater": function (column, row) {
                    return row.OrderCreaterName;
                },
                "OrderWeihu": function (column, row) {
                    return row.OrderWeihuName;
                },
                OrderType: function (column, row) {
                    return GetOptionValue(row.OrderType, "1|月嫂服务,2|育婴师服务,3|会所服务,4|增值产品");
                },
                "commands": function (column, row) {
                    if (row.OrderType == 1) {
                        return "<a href='javascript:order_show(\"" + row.OrderCode + "\")'  style=\"color:blue\">查看</a>";
                    }
                    if (row.OrderType == 2) {
                        return "<a href='javascript:order_show1(\"" + row.OrderCode + "\")'  style=\"color:blue\">查看</a>";
                    }
                    if (row.OrderType == 3) {
                        return "<a href='javascript:order_show2(\"" + row.OrderCode + "\")'  style=\"color:blue\">查看</a>";
                    }
                    if (row.OrderType == 4) {
                        return "<a href='javascript:order_show3(\"" + row.OrderCode + "\")'  style=\"color:blue\">查看</a>";
                    }
                }
            }
        }).on("loaded.rs.jquery.bootgrid", function (e) {
            //按钮提示
            $('.tip').tooltip({ placement: "bottom" });
            //按钮气泡
            $('.pop').popover({ html: true, trigger: "hover" });
            //showMsg("数据加载完毕！", "Success");
        });
    }
    //订单预览界面
    function order_show(order_code) {
        showTopWindow("show_view", "/Order/YuesaoOrder/ViewYuesao?order_code=" + order_code, "查看月嫂订单", 900, 450, function () { }, function () { });
    }
    function order_show1(order_code) {
        showTopWindow("show_view", "/Order/YingshiOrder/ViewYingshi?order_code=" + order_code, "查看育婴师订单", 900, 450, function () { }, function () { });
    }
    function order_show2(order_code) {
        showTopWindow("show_view", "/Order/Corder/ViewHuisuo?order_code=" + order_code, "查看月子会所订单", 900, 450, function () { }, function () { });
    }
    function order_show3(order_code) {
        showTopWindow("show_view", "/Order/Corder/ViewZengzhi?order_code=" + order_code, "查看增值产品订单", 900, 450, function () { }, function () { });
    }    
    function order_trash() {
        var ids = get_selected_ids("order_grid_data");
        //console.log(ids);
        if (ids == "") {
            showTopMsg("请选择你要放入回收站的记录！", "错误提示", "Error");
            return false;
        }
        //console.log(ids);
        //return false;
        showTopDialog("show_order_trash", "<div class='dialog_confirm'>确认将选中记录放入回收站吗？</div>", "温馨提示", 400, 75, function () {
            $.ajax({
                type: "GET",
                cache: false,
                url: "/api/OrderApi/UpdateOrderStatusTrash?ids=" + ids + "&status=0",
                //data: { ids: ids },
                dataType: "json",
                beforeSend: function () {
                    //showMsg("添加中，请稍后...");
                },
                complete: function () {
                    //d.close().remove();
                },
                success: function (result) {
                    //toLowerCase报错
                    //var status = result.Status.toLowerCase();
                    var status = result.Status;
                    if (status == true || status == "true" || status == "True") {
                        //刷新数据
                        order_grid.bootgrid("reload");
                        showMsg("订单放入回收站成功！", "Success");
                    } else {
                        showMsg("系统异常，订单放入回收站失败！", "Error");
                    }
                },
                error: function () {
                    showTopMsg("网络连接错误!", "错误提示", "Error");
                }
            });
        });
        //必须有这个，阻止刷新
        return false;
    }
    function order_update() {
        var ids = get_selected_ids("order_grid_data");
        //console.log(ids);
        if (ids == "") {
            showTopMsg("请选择你更改状态为“执行中”的记录！", "错误提示", "Error");                        
            return false;
        }
      
        //console.log(ids);
        //return false;
        showTopDialog("show_order_trash", "<div class='dialog_confirm'>确认将选中订单的状态更改为“执行中”吗？</div>", "温馨提示", 400, 75, function () {
            $.ajax({
                type: "GET",
                cache: false,
                url: "/api/OrderApi/UpdateOrderStatus?ids=" + ids + "&status=3",
                //data: { ids: ids },
                dataType: "json",
                beforeSend: function () {
                    //showMsg("添加中，请稍后...");
                },
                complete: function () {
                    //d.close().remove();
                },
                success: function (result) {
                    //toLowerCase报错
                    //var status = result.Status.toLowerCase();
                    var status = result.Status;
                    if (status == true || status == "true" || status == "True") {
                        //刷新数据
                        order_grid.bootgrid("reload");
                        showMsg("订单状态更改为“执行中”成功！", "Success");
                    } else {
                        showMsg("系统异常，订单状态更改为“执行中”失败！", "Error");
                    }
                },
                error: function () {
                    showTopMsg("网络连接错误!", "错误提示", "Error");
                }
            });
        });
        //必须有这个，阻止刷新
        return false;
    }
    function order_wan() {
        var ids = get_selected_ids("order_grid_data");
        //console.log(ids);
        if (ids == "") {
            showTopMsg("请选择你更改状态为“完成”的记录！", "错误提示", "Error");
            return false;
        }
        //console.log(ids);
        //return false;
        showTopDialog("show_order_trash", "<div class='dialog_confirm'>确认将选中订单的状态更改为“完成”吗？</div>", "温馨提示", 400, 75, function () {
            $.ajax({
                type: "GET",
                cache: false,
                url: "/api/OrderApi/UpdateOrderStatusWan?ids=" + ids + "&status=4",
                //data: { ids: ids },
                dataType: "json",
                beforeSend: function () {
                    //showMsg("添加中，请稍后...");
                },
                complete: function () {
                    //d.close().remove();
                },
                success: function (result) {
                    //toLowerCase报错
                    //var status = result.Status.toLowerCase();
                    var status = result.Status;
                    if (status == true || status == "true" || status == "True") {
                        //刷新数据
                        order_grid.bootgrid("reload");
                        showMsg("订单状态更改为“完成”成功！", "Success");
                    } else {
                        showMsg("系统异常，订单状态更改为“完成”失败！", "Error");
                    }
                },
                error: function () {
                    showTopMsg("网络连接错误!", "错误提示", "Error");
                }
            });
        });
        //必须有这个，阻止刷新
        return false;
    }
    function order_transfer() {
        var ids = get_selected_ids("order_grid_data");
        //console.log(ids);
        if (ids == "") {
            showTopMsg("请选择你要转移的订单！", "错误提示", "Error");
            return false;
        }
        //console.log(ids);
        //return false;
        showTopWindow("show_list_user", " /Order/Order/ShowTransferUsers/", "选择要转移的订单", 550, 300, function () {
            var userIds = top.window.document.getElementById("frm_show_list_user").contentWindow.get_selected_user_ids();
            //必须选择一个用户
            if ("" == userIds) {
                return false;
            }
            var transfer_url = "/api/OrderApi/UpdateClientInfoWeihu?ids=" + ids + "&userId=" + userIds;
            //alert(transfer_url);
            //return false;
            showTopDialog("show_clientinfo_trash", "<div class='dialog_confirm'>确认将选中订单转移吗？</div>", "温馨提示", 400, 75, function () {
                $.ajax({
                    type: "GET",
                    cache: false,
                    url: transfer_url,
                    //data: { ids: ids },
                    dataType: "json",
                    beforeSend: function () {
                        //showMsg("添加中，请稍后...");
                    },
                    complete: function () {
                        //d.close().remove();
                    },
                    success: function (result) {
                        //toLowerCase报错
                        //var status = result.Status.toLowerCase();
                        var status = result.Status;
                        if (status == true || status == "true" || status == "True") {
                            //刷新数据
                            order_grid.bootgrid("reload");
                            showMsg("订单转移成功！", "Success");
                        } else {
                            showMsg("系统异常，订单转移失败！", "Error");
                        }
                    },
                    error: function () {
                        showTopMsg("网络连接错误!", "错误提示", "Error");
                    }
                });
            });

        }, function () { });
        //必须有这个，阻止刷新
        return false;
    }       
         </script>
    
 </head>
    <body>

<div>
    <table id="order_grid_data" class="table table-condensed table-hover table-striped table-bordered" data-selection="true" data-multi-select="true">
        <thead>
            <tr>
	  <th data-column-id="OrderCode" data-header-align="center"  data-formatter="OrderCode" data-order="desc" data-header-css-class="wid140">订单编号</th>
		  <th data-column-id="OrderType" data-header-align="center"  data-formatter="OrderType" data-order="desc">类型</th>
		  <th data-column-id="OrderEnd" data-header-align="center"  data-formatter="OrderEnd" data-order="desc" data-header-css-class="wid200">服务时间</th>
		  <th data-column-id="OrderStatus" data-header-align="center"  data-formatter="OrderStatus" data-order="desc">状态</th>
		  <th data-column-id="OrderSumMoney" data-header-align="center"  data-formatter="OrderSumMoney" data-order="desc">金额</th>
		  <th data-column-id="OrderCreater" data-header-align="center"  data-formatter="OrderCreater" data-order="desc">创建人</th>
		  <th data-column-id="OrderWeihu" data-header-align="center"  data-formatter="OrderWeihu" data-order="desc">维护人</th>
		  <th data-column-id="OrderDate" data-header-align="center"  data-formatter="OrderDate" data-order="desc" data-header-css-class="wid90">下单日期</th>
		  <th data-column-id="OrderProcesstime" data-header-align="center"  data-formatter="OrderProcesstime" data-order="desc" data-header-css-class="wid90">处理日期</th>
		  <th data-column-id="Id" data-type="numeric" data-identifier="true" data-formatter="commands" data-sortable="false">操作</th>
		    </tr>
        </thead>
    </table>
</div>

</body>
</html>


